package edu.iiitb.studentinfo.action;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import edu.iiitb.studentinfo.model.Student;
import edu.iiitb.studentinfo.service.EditProfileService;
import edu.iiitb.studentinfo.service.StudentService;

public class EditProfileAction extends ActionSupport {

    /**
	 * 
	 */
	private static final long serialVersionUID = 1026390541153518676L;
	private int studentId;
    private Student studentBean;
	private String firstName;
	private String lastName;
	private String RollNo;
	
	private String email;
	private String phone;
  

public String show() {
	Map session = ActionContext.getContext().getSession();
	studentId=(Integer) session.get("userid");
	StudentService studentService = new StudentService();
	studentBean = studentService.getStudentInfo(studentId);
	this.setStudentBean(studentBean);
	System.out.println("studentId="+studentId);
	System.out.println("first name="+studentBean.getFirstName());
	System.out.println("last name="+studentBean.getLastName());
	System.out.println("roll no="+studentBean.getRollNo());
	System.out.println("email="+studentBean.getEmail());
	
	return "success";



}
public String execute() {
	Map session = ActionContext.getContext().getSession();
	studentId=(Integer) session.get("userid");
	EditProfileService eps = new EditProfileService();
	/*studentBean.setFirstName(this.getFirstName());
    studentBean.setLastName(this.getLastName());
	studentBean.setRollNo(this.getRollNo());
	studentBean.setEmail(this.getEmail());  
	studentBean.setPhone(this.getPhone());*/
	System.out.println(firstName);
	System.out.println(lastName);
	System.out.println(RollNo);
	System.out.println(email);
	System.out.println(phone);
	this.studentId = eps.UpdateProfile(firstName,lastName,RollNo,email,phone);
//	session=ActionContext.getContext().getSession();
//	session.pu("userid", this.studentId);
//	this.studentId = 
	return "success";

}
public int getStudentId() {
	return studentId;
}
public void setStudentId(int studentId) {
	this.studentId = studentId;
}
public Student getStudentBean() {
	return studentBean;
}
public void setStudentBean(Student studentBean) {
	this.studentBean = studentBean;
}
public String getFirstName() {
	return firstName;
}
public void setFirstName(String firstName) {
	this.firstName = firstName;
}
public String getLastName() {
	return lastName;
}
public void setLastName(String lastName) {
	this.lastName = lastName;
}
public String getRollNo() {
	return RollNo;
}
public void setRollNo(String rollNo) {
	RollNo = rollNo;
}
public String getEmail() {
	return email;
}
public void setEmail(String email) {
	this.email = email;
}
public String getPhone() {
	return phone;
}
public void setPhone(String phone) {
	this.phone = phone;
}





	

}
